<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .long {
      width: 200px;
      height: 10px;
      background-color: yellow;
      border-radius: 5px;
    }
    .short {
      width: 140px;
      height: 10px;
      margin: 0 auto;
      background-color: red;
    }
  </style>
</head>

<body>
  <div id="app">
    <p>watch</p>
    <input type="text" v-model="person.age">
    <p>{{totalPrice}}</p>
    <div class="long" :style="{transform: 'scale('+time+', 1)'}">
      <div class="short"></div>
    </div>
    <button @click="long">long</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        val1: '',
        time: 1,
        person: {
          name: 'Jack',
          age: 18,
        },
        goods: [
          { name: 'apple', num: 10, price: 5 },
          { name: 'banana', num: 18, price: 7 },
          { name: 'orange', num: 9, price: 5 },
        ]
      },
      computed: {
        totalPrice: {
          // getter
          get: function () {
            let num = 0;
            this.goods.forEach(item => {
              num += item.price * item.num;
            });
            return num
          },
          // setter
          set: function (newValue) {
            var names = newValue.split(' ')
            this.firstName = names[0]
            this.lastName = names[names.length - 1]
          }


        }
      },
      methods: {
        long() {

        }
      },
    })
  </script>
</body>

</html>